package testes;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import javax.swing.JOptionPane;


public class TestaInsercaoDadosUsuarios1 {
	
	public static void main(String[] args) {
		Connection con;
		
		
		
		String nome = JOptionPane.showInputDialog
				("Informe o nome: ");
		String cpf = JOptionPane.showInputDialog
				("Informe o cpf: ");
		String telefone = JOptionPane.showInputDialog
				("Informe o telefone: ");
		
		try {
			con = DriverManager.getConnection
					("jdbc:oracle:thin:@localhost:1521:xe",
							"wagner","java");
			
			
			PreparedStatement pstm = con.prepareStatement
					("insert into cliente (cd_cli,nm_cli,cpf_cli,cel_cli)"
							+ "values (sq_cd_cli.nextval,?,?,?)");
			
			
			pstm.setString(1, nome);
			pstm.setString(2, cpf);
			pstm.setString(3, telefone);
			
			pstm.execute();
			
			
			JOptionPane.showMessageDialog(null, "Inseriu com "
					+ "sucesso");
			
		} catch (SQLException e) {
			JOptionPane.showMessageDialog(null, "Errou" +
					e.getMessage());
			
			e.printStackTrace();
		} 
		
		
		
	}

}
